import { defineStore } from 'pinia';

export const useAuthStore = defineStore('auth', {
    state: () => ({
        id: null,
        username: '',
        token: '',
        role: '',
    }),
    actions: {
        setAuthData({ id, username, token, role }) {
            this.id = id;
            this.username = username;
            this.token = token;
            this.role = role;
        },
        clearAuthData() {
            this.id = null;
            this.username = '';
            this.token = '';
            this.role = '';
        }
    },
    persist: {
        key: 'userInfo',
    },
});
